package com.cfets.annualAssessment.service;

import com.cfets.annualAssessment.entity.CfetsCookie;
import com.cfets.annualAssessment.mapper.CfetsCookieMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

/**
 * @author DavidSun
 * @create 2018-12-19 9:32
 * @desc cfetscookie 应用层
 **/
@Service
public class CfetsCookieService {
    @Autowired
    private CfetsCookieMapper cfetsCookieMapper;


    // 根据newId 删除cookie
    public int  deleteCfetsCookiesByCookie(CfetsCookie cfetsCookie){
       // return  cfetsCookieMapper.deleteByPrimaryKey(id)>0;
        Example example = new Example(CfetsCookie.class);
        Example.Criteria criteria = example.createCriteria();

        criteria.andLike("cookie","%"+cfetsCookie.getCookie()+"%");

        return cfetsCookieMapper.deleteByExample(example);
    }

    // 插入数据
    public int insertCfetsCookie (CfetsCookie cfetsCookie) {
        return  cfetsCookieMapper.insert(cfetsCookie);
    }

    // 根据 id 来获取cookie数据
    public  List<CfetsCookie> getCfetsCookieById(int id){
        CfetsCookie cfetsCookie = new CfetsCookie();
        cfetsCookie.setNewid(id);
       // return  cfetsCookieMapper.selectByPrimaryKey(id);
        return  cfetsCookieMapper.select(cfetsCookie);
    }



}
